package com.css.gdzj.gdzjbxgd.common.menu;

import com.css.aq.server.service.BaseService;
import com.css.gdzj.gdzjbxgd.common.util.R;
import com.css.gdzj.gdzjbxgd.modules.userinfo.repository.entity.UserInfoEntity;
import com.css.gdzj.gdzjbxgd.sys.user.entity.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/sys")
public class GetSysController {
    @Autowired
    private BaseService baseService;
    @Autowired
    private HttpServletRequest request;
    @Value("${BASE_URL}")
    private String BASE_URL;
    @GetMapping("/getsys")
    public R getSys(){
        HttpSession session=request.getSession();
        UserInfoEntity userInfo = (UserInfoEntity) session.getAttribute("_USER_LOGIN_INFO_");
        List<Map<String,Object>> sysApp = new ArrayList<>();
        return R.ok().put("data",sysApp);
    }
    /*public  List<Map<String,Object>> getMenu(LoginUser userInfo,String appCode) {
        String id = userInfo.getUserId();
        // 根据用户id和子系统code获取菜单信息
        String url = BASE_URL + "/platform/api/sys/menus/userid/" + id + "/appcode/" + appCode;
        Map<String, String> map = new HashMap<>();
        HttpMethod method = HttpMethod.GET;
        Map body = RestfulUtil.sendRestful(request, map, url, method);
        String data = JSONObject.toJSONString(body.get("data"));
        JSONArray result = JSONArray.parseArray(data);
        List<Map<String,Object>> meuList = (List<Map<String, Object>>) JSONArray.parse(data);
        return meuList;
    }*/
}
